package prober;

import java.util.Collections;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

/**
 * The Word frequencies storage.
 * 
 * @author Vika
 * @author ak2765
 */
public class WordFrequencies {

	private SortedMap<String,Long> wordFrequencies = new TreeMap<String,Long>();

	public void addWord(String word) {
		if (wordFrequencies.containsKey(word)) {
			Long count = wordFrequencies.get(word);
			wordFrequencies.put(word, ++count);
		} else {
			wordFrequencies.put(word, 1L);
		}
	}
	
	public Map<String,Long> getFrequencies() {
		return Collections.unmodifiableMap(this.wordFrequencies);
	}

	@Override
	public String toString() {
		return "WordFrequencies [wordFrequencies=" + wordFrequencies + "]";
	}
}
